package tests;

import common.AutoTestUtil;
import org.openqa.selenium.By;

public class PageExit extends AutoTestUtil {
    /**
     * 用户点击退出测试
     */
    public void successExit(){
        //进行刷新的操作
        driver.navigate().refresh();

        //然后进行查找
        driver.findElement(By.cssSelector("#index_nav_name_sub")).click();

        driver.findElement(By.cssSelector("#index_user_logout > span")).click();

        //进行判断是否退出成功
        try {
            String targetName = driver.findElement(By.cssSelector("body > div > div > div > div:nth-child(1) > div > div.card.card-md > div > h2")).getText();
            if(targetName.equals("用户登录")){
                System.out.println("用户退出成功");
            }
            getScreen(this.getClass().getMethod("successExit").getName());
        }catch (Exception e){
            System.out.println("successExit方法出现异常：" + e);
        }

        //driver.quit();
    }
}
